package ar.com.spsolutions.splilabrary.view.application;

import org.apache.log4j.Logger;
import org.apache.wicket.Page;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.markup.html.WebPage;
import org.springframework.security.authentication.AuthenticationManager;

import ar.com.spsolutions.splibrary.examplebd.DataBasePopulator;
import ar.com.spsolutions.splibrary.general.RoleConverterService;
import ar.com.spsolutions.splibrary.notifiers.INotifier;
import ar.com.spsolutions.splibrary.services.EntityService;
import ar.com.spsolutions.splilabrary.view.application.configuration.ApplicationConfiguration;
import ar.com.spsolutions.splilabrary.view.pages.Home;
import ar.com.spsolutions.splilabrary.view.pages.SignInPage;
import ar.com.spsolutions.splilabrary.view.utils.MounterURL;

public class SPApplication extends AuthenticatedWebApplication {
	protected static final Logger LOG = Logger.getLogger(SPApplication.class);
	private EntityService generalService;

	private INotifier notifier;

	private MounterURL mounterURL;

	private RoleConverterService converterService;

	private AuthenticationManager authenticationManager;
	private DataBasePopulator dataBasePopulator;

	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		return SignInPage.class;
	}

	@Override
	protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
		return WebSession.class;
	}

	@Override
	public Class<? extends Page> getHomePage() {
		return Home.class;
	}

	@Override
	protected void init() {
		super.init();
		new ApplicationConfiguration(this).initialize();
	}

	public String getContextPath() {
		return this.getServletContext().getContextPath();
	}

	// --accessors--
	public INotifier getNotifier() {
		return this.notifier;
	}

	public void setNotifier(final INotifier notifier) {
		this.notifier = notifier;
	}

	public MounterURL getMounterURL() {
		return this.mounterURL;
	}

	public void setMounterURL(final MounterURL mounterURL) {
		this.mounterURL = mounterURL;
	}

	public EntityService getGeneralService() {
		return this.generalService;
	}

	public void setGeneralService(final EntityService generalService) {
		this.generalService = generalService;
	}

	public RoleConverterService getConverterService() {
		return this.converterService;
	}

	public void setConverterService(final RoleConverterService converterService) {
		this.converterService = converterService;
	}

	public AuthenticationManager getAuthenticationManager() {
		return this.authenticationManager;
	}

	public void setAuthenticationManager(
			final AuthenticationManager authenticationManager) {
		this.authenticationManager = authenticationManager;
	}

	public DataBasePopulator getDataBasePopulator() {
		return this.dataBasePopulator;
	}

	public void setDataBasePopulator(final DataBasePopulator dataBasePopulator) {
		this.dataBasePopulator = dataBasePopulator;
	}

}
